﻿using MengLin.OOP.DesignPattern.Adapter.ServiceCanUsed.Implements;
using MengLin.OOP.DesignPattern.Adapter.ServiceCanUsed.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.Adapter.ServiceCanUsed
{
    /// <summary>
    /// 组合方式
    /// </summary>
    public class RedisComposeHelper : IDBHelper
    {
        //RedisHelper _redisHelper = new RedisHelper();
        RedisHelper _redisHelper = null;

        public RedisComposeHelper()
        {

        }

        /// <summary>
        /// 构造函数注入
        ///</summary>
        public RedisComposeHelper(RedisHelper redisHelper)
        {
            _redisHelper = redisHelper;
        }

        /// <summary>
        /// 方法注入
        /// </summary>
        /// <param name="redisHelper"></param>
        public void SetRedisHelper(RedisHelper redisHelper)
        {
            _redisHelper = redisHelper;
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public void Add<T>()
        {
            _redisHelper.AddRedis<T>();
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public void Update<T>()
        {
            _redisHelper.UpdateRedis<T>();
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public void Delete<T>()
        {
            _redisHelper.DeleteRedis<T>();
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public void Query<T>()
        {
            _redisHelper.QueryRedis<T>();
        }
    }
}
